﻿Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            'Set molecular viewer control to read the file selected
            Dim sfile = OpenFileDialog1.FileName

            AxLPMolecViewer1.FileLocation = sfile

            Me.Refresh()

        End If
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        NumHeight.Value = AxLPMolecViewer1.Height
        NumWidth.Value = AxLPMolecViewer1.Width
    End Sub


    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim sfile = SaveFileDialog1.FileName

            Dim oldh, oldw As Integer

            oldh = AxLPMolecViewer1.Height
            oldw = AxLPMolecViewer1.Width

            'Sets AXControl to new size
            AxLPMolecViewer1.Height = NumHeight.Value
            AxLPMolecViewer1.Width = NumWidth.Value

            Me.Refresh()
            AxLPMolecViewer1.Refresh()
            'System.Threading.Thread.Sleep(1000) 'wait 1sec

            'save here
            AxLPMolecViewer1.SaveMolToPNG(sfile)

            AxLPMolecViewer1.Height = oldh
            AxLPMolecViewer1.Width = oldw

            Me.Refresh()

        End If
    End Sub
End Class
